package cn.com.leon.controller.action;

import cn.com.leon.controller.BaseAction;
import cn.com.leon.model.GradeClass;
import cn.com.leon.model.Student;

public class StudentAction extends BaseAction<Student> {

	public StudentAction(){
		super("students");
	}
	
	@Override
	public boolean del(Student entity) {
		super.del(entity);
		GradeClass tmpClass = entity.getGradeClass();
		tmpClass.setNum(tmpClass.getNum()-1);
		new GradeClassAction().update(tmpClass);
		return true;
	}
	
	

	@Override
	public boolean insert(Student entity) {
		GradeClass tmpClass = entity.getGradeClass();
		tmpClass.setNum(tmpClass.getNum()+1);
		entity.setGradeClass(tmpClass);
		if(super.insert(entity)){
			new GradeClassAction().update(tmpClass);
			return true;
		}else{
			return false;
		}
	}



	private static final long serialVersionUID = 7135867644919124821L;
	
}
